﻿using System;
using System.Collections.Generic;
using Helpers;
using TaleWorlds.CampaignSystem.Actions;
using TaleWorlds.CampaignSystem.CharacterDevelopment;
using TaleWorlds.CampaignSystem.Conversation;
using TaleWorlds.CampaignSystem.MapEvents;
using TaleWorlds.CampaignSystem.Party;
using TaleWorlds.CampaignSystem.Roster;
using TaleWorlds.CampaignSystem.Settlements;
using TaleWorlds.Core;
using TaleWorlds.Library;
using TaleWorlds.Localization;
using TaleWorlds.SaveSystem;

namespace TaleWorlds.CampaignSystem.Issues
{
	// Token: 0x0200030A RID: 778
	public class HeadmanVillageNeedsDraughtAnimalsIssueBehavior : CampaignBehaviorBase
	{
		// Token: 0x06002D35 RID: 11573 RVA: 0x000BD3EF File Offset: 0x000BB5EF
		public override void RegisterEvents()
		{
			CampaignEvents.OnCheckForIssueEvent.AddNonSerializedListener(this, new Action<Hero>(this.OnCheckForIssue));
		}

		// Token: 0x06002D36 RID: 11574 RVA: 0x000BD408 File Offset: 0x000BB608
		public override void SyncData(IDataStore dataStore)
		{
		}

		// Token: 0x06002D37 RID: 11575 RVA: 0x000BD40C File Offset: 0x000BB60C
		private bool ConditionsHold(Hero issueGiver)
		{
			if (issueGiver.CurrentSettlement != null && issueGiver.IsHeadman)
			{
				Village village = issueGiver.CurrentSettlement.Village;
				return (village.GetProsperityLevel() == SettlementComponent.ProsperityLevel.Low || village.GetProsperityLevel() == SettlementComponent.ProsperityLevel.Mid) && (village.VillageType == DefaultVillageTypes.IronMine || village.VillageType == DefaultVillageTypes.ClayMine || village.VillageType == DefaultVillageTypes.SaltMine || village.VillageType == DefaultVillageTypes.SilverMine || village.VillageType == DefaultVillageTypes.Lumberjack);
			}
			return false;
		}

		// Token: 0x06002D38 RID: 11576 RVA: 0x000BD490 File Offset: 0x000BB690
		public void OnCheckForIssue(Hero hero)
		{
			if (this.ConditionsHold(hero))
			{
				Campaign.Current.IssueManager.AddPotentialIssueData(hero, new PotentialIssueData(new PotentialIssueData.StartIssueDelegate(this.OnSelected), typeof(HeadmanVillageNeedsDraughtAnimalsIssueBehavior.HeadmanVillageNeedsDraughtAnimalsIssue), IssueBase.IssueFrequency.VeryCommon, null));
				return;
			}
			Campaign.Current.IssueManager.AddPotentialIssueData(hero, new PotentialIssueData(typeof(HeadmanVillageNeedsDraughtAnimalsIssueBehavior.HeadmanVillageNeedsDraughtAnimalsIssue), IssueBase.IssueFrequency.VeryCommon));
		}

		// Token: 0x06002D39 RID: 11577 RVA: 0x000BD4F4 File Offset: 0x000BB6F4
		private IssueBase OnSelected(in PotentialIssueData pid, Hero issueOwner)
		{
			return new HeadmanVillageNeedsDraughtAnimalsIssueBehavior.HeadmanVillageNeedsDraughtAnimalsIssue(issueOwner);
		}

		// Token: 0x04000D8C RID: 3468
		private const IssueBase.IssueFrequency HeadmanVillageNeedsDraughtAnimalsIssueFrequency = IssueBase.IssueFrequency.VeryCommon;

		// Token: 0x02000630 RID: 1584
		public class HeadmanVillageNeedsDraughtAnimalsIssue : IssueBase
		{
			// Token: 0x06004D0F RID: 19727 RVA: 0x00161934 File Offset: 0x0015FB34
			internal static void AutoGeneratedStaticCollectObjectsHeadmanVillageNeedsDraughtAnimalsIssue(object o, List<object> collectedObjects)
			{
				((HeadmanVillageNeedsDraughtAnimalsIssueBehavior.HeadmanVillageNeedsDraughtAnimalsIssue)o).AutoGeneratedInstanceCollectObjects(collectedObjects);
			}

			// Token: 0x06004D10 RID: 19728 RVA: 0x00161942 File Offset: 0x0015FB42
			protected override void AutoGeneratedInstanceCollectObjects(List<object> collectedObjects)
			{
				base.AutoGeneratedInstanceCollectObjects(collectedObjects);
				collectedObjects.Add(this._selectedAnimal);
			}

			// Token: 0x06004D11 RID: 19729 RVA: 0x00161957 File Offset: 0x0015FB57
			internal static object AutoGeneratedGetMemberValue_selectedAnimal(object o)
			{
				return ((HeadmanVillageNeedsDraughtAnimalsIssueBehavior.HeadmanVillageNeedsDraughtAnimalsIssue)o)._selectedAnimal;
			}

			// Token: 0x06004D12 RID: 19730 RVA: 0x00161964 File Offset: 0x0015FB64
			internal static object AutoGeneratedGetMemberValue_isQuestWithMeatOffer(object o)
			{
				return ((HeadmanVillageNeedsDraughtAnimalsIssueBehavior.HeadmanVillageNeedsDraughtAnimalsIssue)o)._isQuestWithMeatOffer;
			}

			// Token: 0x06004D13 RID: 19731 RVA: 0x00161976 File Offset: 0x0015FB76
			internal static object AutoGeneratedGetMemberValue_requestedAnimalAmount(object o)
			{
				return ((HeadmanVillageNeedsDraughtAnimalsIssueBehavior.HeadmanVillageNeedsDraughtAnimalsIssue)o)._requestedAnimalAmount;
			}

			// Token: 0x17000FB9 RID: 4025
			// (get) Token: 0x06004D14 RID: 19732 RVA: 0x00161988 File Offset: 0x0015FB88
			public override IssueBase.AlternativeSolutionScaleFlag AlternativeSolutionScaleFlags
			{
				get
				{
					return IssueBase.AlternativeSolutionScaleFlag.Duration;
				}
			}

			// Token: 0x17000FBA RID: 4026
			// (get) Token: 0x06004D15 RID: 19733 RVA: 0x0016198B File Offset: 0x0015FB8B
			private ItemObject _meatItem
			{
				get
				{
					return Game.Current.ObjectManager.GetObject<ItemObject>("meat");
				}
			}

			// Token: 0x17000FBB RID: 4027
			// (get) Token: 0x06004D16 RID: 19734 RVA: 0x001619A1 File Offset: 0x0015FBA1
			private int OfferedMeatAmount
			{
				get
				{
					return (300 + this._selectedAnimal.Value * this._requestedAnimalAmount) / this._meatItem.Value * 2;
				}
			}

			// Token: 0x17000FBC RID: 4028
			// (get) Token: 0x06004D17 RID: 19735 RVA: 0x001619C9 File Offset: 0x0015FBC9
			private int GoldRequiredForAlternativeSolution
			{
				get
				{
					return (int)((float)(this._selectedAnimal.Value * this._requestedAnimalAmount) * 0.7f);
				}
			}

			// Token: 0x17000FBD RID: 4029
			// (get) Token: 0x06004D18 RID: 19736 RVA: 0x001619E5 File Offset: 0x0015FBE5
			public override int AlternativeSolutionBaseNeededMenCount
			{
				get
				{
					return 3 + MathF.Ceiling(3f * base.IssueDifficultyMultiplier);
				}
			}

			// Token: 0x17000FBE RID: 4030
			// (get) Token: 0x06004D19 RID: 19737 RVA: 0x001619FA File Offset: 0x0015FBFA
			protected override int AlternativeSolutionBaseDurationInDaysInternal
			{
				get
				{
					return 3 + MathF.Ceiling(5f * base.IssueDifficultyMultiplier);
				}
			}

			// Token: 0x17000FBF RID: 4031
			// (get) Token: 0x06004D1A RID: 19738 RVA: 0x00161A0F File Offset: 0x0015FC0F
			protected override int RewardGold
			{
				get
				{
					if (this._isQuestWithMeatOffer)
					{
						return 0;
					}
					return 500 + this._selectedAnimal.Value * this._requestedAnimalAmount;
				}
			}

			// Token: 0x17000FC0 RID: 4032
			// (get) Token: 0x06004D1B RID: 19739 RVA: 0x00161A33 File Offset: 0x0015FC33
			public override TextObject IssueBriefByIssueGiver
			{
				get
				{
					return new TextObject("{=9nxTUZkO}We do have a problem. Last winter was hard on our animals. A number died from disease, and others were taken by wolves. We'd go to town to buy more, but, well, herds make a tempting target for bandits and we're not really suited to fight them. We can't afford to slaughter even the oldest and weakest of our animals because we need them to pull the plough. Maybe you can help us?[if:convo_grave][ib:demure2]", null);
				}
			}

			// Token: 0x17000FC1 RID: 4033
			// (get) Token: 0x06004D1C RID: 19740 RVA: 0x00161A40 File Offset: 0x0015FC40
			public override TextObject IssueAcceptByPlayer
			{
				get
				{
					return new TextObject("{=nvaLVB5f}Tell me your needs.", null);
				}
			}

			// Token: 0x17000FC2 RID: 4034
			// (get) Token: 0x06004D1D RID: 19741 RVA: 0x00161A50 File Offset: 0x0015FC50
			public override TextObject IssueQuestSolutionExplanationByIssueGiver
			{
				get
				{
					TextObject textObject = TextObject.Empty;
					if (this._isQuestWithMeatOffer)
					{
						textObject = new TextObject("{=aExKdXmx}We need {REQUESTED_ANIMAL_AMOUNT} {.%}{?(REQUESTED_ANIMAL_AMOUNT > 1)}{PLURAL(SELECTED_ANIMAL)}{?}{SELECTED_ANIMAL}{\\?}{.%}.[if:convo_normal][ib:demure] To be honest our village is poor and our coffers are empty. We can make payment only as meat - the meat of the old animals that we'll slaughter as soon as you bring us the new ones. We can offer {MEAT_AMOUNT} loads of meat, will you accept that, {?PLAYER.GENDER}madam{?}sir{\\?}?", null);
						textObject.SetTextVariable("MEAT_AMOUNT", this.OfferedMeatAmount);
					}
					else
					{
						textObject = new TextObject("{=TEhwK74M}We are willing to pay {REWARD}{GOLD_ICON} denars for {REQUESTED_ANIMAL_AMOUNT} healthy and strong [if:convo_normal][ib:demure]{.%}{?(REQUESTED_ANIMAL_AMOUNT > 1)}{PLURAL(SELECTED_ANIMAL)}{?}{SELECTED_ANIMAL}{\\?}{.%}. Unlike us, I'm sure you can travel distant villages easily and find the finest and cheapest ones there.", null);
						textObject.SetTextVariable("REWARD", this.RewardGold);
					}
					textObject.SetTextVariable("REQUESTED_ANIMAL_AMOUNT", this._requestedAnimalAmount);
					textObject.SetTextVariable("SELECTED_ANIMAL", this._selectedAnimal.Name);
					textObject.SetTextVariable("GOLD_ICON", "{=!}<img src=\"General\\Icons\\Coin@2x\" extend=\"8\">");
					return textObject;
				}
			}

			// Token: 0x17000FC3 RID: 4035
			// (get) Token: 0x06004D1E RID: 19742 RVA: 0x00161AE4 File Offset: 0x0015FCE4
			public override TextObject IssuePlayerResponseAfterAlternativeExplanation
			{
				get
				{
					return new TextObject("{=qYSrlr4q}Maybe I should send one of my men to find the animals you need.", null);
				}
			}

			// Token: 0x17000FC4 RID: 4036
			// (get) Token: 0x06004D1F RID: 19743 RVA: 0x00161AF4 File Offset: 0x0015FCF4
			public override TextObject IssueAlternativeSolutionExplanationByIssueGiver
			{
				get
				{
					TextObject textObject = new TextObject("{=bvEOmHWd}I think a man who knows how to trade alongside {ALTERNATIVE_TROOP_AMOUNT} [if:convo_undecided_open]fighters can get the job done without trouble. they will need {GOLD_REQUIRED_FOR_ALTERNATIVE_SOLUTION}{GOLD_ICON} denars to buy the animals. You or one of your companions, {?PLAYER.GENDER}madam{?}sir{\\?} - it doesn't matter for us as long as you find the animals we need...", null);
					textObject.SetTextVariable("ALTERNATIVE_TROOP_AMOUNT", base.GetTotalAlternativeSolutionNeededMenCount());
					textObject.SetTextVariable("GOLD_REQUIRED_FOR_ALTERNATIVE_SOLUTION", this.GoldRequiredForAlternativeSolution);
					textObject.SetTextVariable("GOLD_ICON", "{=!}<img src=\"General\\Icons\\Coin@2x\" extend=\"8\">");
					return textObject;
				}
			}

			// Token: 0x17000FC5 RID: 4037
			// (get) Token: 0x06004D20 RID: 19744 RVA: 0x00161B41 File Offset: 0x0015FD41
			public override TextObject IssueQuestSolutionAcceptByPlayer
			{
				get
				{
					return new TextObject("{=iq3yEuO9}All right. I will bring your animals by myself.", null);
				}
			}

			// Token: 0x17000FC6 RID: 4038
			// (get) Token: 0x06004D21 RID: 19745 RVA: 0x00161B4E File Offset: 0x0015FD4E
			public override TextObject IssueAlternativeSolutionAcceptByPlayer
			{
				get
				{
					return new TextObject("{=BMQQSeTp}I'm sure my men will find what you need and bring them to you in time.", null);
				}
			}

			// Token: 0x17000FC7 RID: 4039
			// (get) Token: 0x06004D22 RID: 19746 RVA: 0x00161B5B File Offset: 0x0015FD5B
			public override TextObject IssueAlternativeSolutionResponseByIssueGiver
			{
				get
				{
					return new TextObject("{=D9LxQxNa}Thank you for your help {?PLAYER.GENDER}madam{?}sir{\\?}.[if:convo_bemused][ib:demure2] We will be waiting for your men. Good luck to you all.", null);
				}
			}

			// Token: 0x17000FC8 RID: 4040
			// (get) Token: 0x06004D23 RID: 19747 RVA: 0x00161B68 File Offset: 0x0015FD68
			public override TextObject IssueDiscussAlternativeSolution
			{
				get
				{
					return new TextObject("{=jol73R8f}We are still waiting for your men to arrive, {?PLAYER.GENDER}ma'am{?}sir{\\?}. The village needs the animals they are bringing.", null);
				}
			}

			// Token: 0x17000FC9 RID: 4041
			// (get) Token: 0x06004D24 RID: 19748 RVA: 0x00161B75 File Offset: 0x0015FD75
			public override bool IsThereAlternativeSolution
			{
				get
				{
					return true;
				}
			}

			// Token: 0x17000FCA RID: 4042
			// (get) Token: 0x06004D25 RID: 19749 RVA: 0x00161B78 File Offset: 0x0015FD78
			public override bool IsThereLordSolution
			{
				get
				{
					return false;
				}
			}

			// Token: 0x17000FCB RID: 4043
			// (get) Token: 0x06004D26 RID: 19750 RVA: 0x00161B7C File Offset: 0x0015FD7C
			protected override TextObject AlternativeSolutionStartLog
			{
				get
				{
					TextObject textObject = new TextObject("{=F16k4H7R}{QUEST_GIVER.LINK} told you that {?QUEST_GIVER.GENDER}she{?}he{\\?} needs {.%}{?(REQUESTED_ANIMAL_AMOUNT > 1)}{PLURAL(SELECTED_ANIMAL)}{?}{SELECTED_ANIMAL}{\\?}{.%} for {?QUEST_GIVER.GENDER}her{?}his{\\?} village. {?QUEST_GIVER.GENDER}She{?}He{\\?} will pay you {REWARD_GOLD}{GOLD_ICON} denars when the animals are delivered. You asked your {COMPANION.LINK} and {ALTERNATIVE_TROOP_AMOUNT} of your men to deliver {REQUESTED_ANIMAL_AMOUNT} {.%}{?(REQUESTED_ANIMAL_AMOUNT > 1)}{PLURAL(SELECTED_ANIMAL)}{?}{SELECTED_ANIMAL}{\\?}{.%} to {QUEST_GIVER.LINK}. They will rejoin your party in {RETURN_DAYS} days.", null);
					textObject.SetTextVariable("ALTERNATIVE_TROOP_AMOUNT", base.GetTotalAlternativeSolutionNeededMenCount());
					textObject.SetTextVariable("REQUESTED_ANIMAL_AMOUNT", this._requestedAnimalAmount);
					textObject.SetTextVariable("SELECTED_ANIMAL", this._selectedAnimal.Name);
					textObject.SetTextVariable("RETURN_DAYS", base.GetTotalAlternativeSolutionDurationInDays());
					textObject.SetTextVariable("REWARD_GOLD", this.RewardGold);
					textObject.SetTextVariable("GOLD_ICON", "{=!}<img src=\"General\\Icons\\Coin@2x\" extend=\"8\">");
					StringHelpers.SetCharacterProperties("QUEST_GIVER", base.IssueOwner.CharacterObject, textObject, false);
					StringHelpers.SetCharacterProperties("COMPANION", base.AlternativeSolutionHero.CharacterObject, textObject, false);
					return textObject;
				}
			}

			// Token: 0x17000FCC RID: 4044
			// (get) Token: 0x06004D27 RID: 19751 RVA: 0x00161C36 File Offset: 0x0015FE36
			public override TextObject Title
			{
				get
				{
					return new TextObject("{=MXLcZPaO}Village Needs Draught Animals", null);
				}
			}

			// Token: 0x17000FCD RID: 4045
			// (get) Token: 0x06004D28 RID: 19752 RVA: 0x00161C43 File Offset: 0x0015FE43
			public override TextObject Description
			{
				get
				{
					return new TextObject("{=Ntv5KPFe}Headman in the village requested draught animals to replace them with old ones.", null);
				}
			}

			// Token: 0x06004D29 RID: 19753 RVA: 0x00161C50 File Offset: 0x0015FE50
			public HeadmanVillageNeedsDraughtAnimalsIssue(Hero issueOwner) : base(issueOwner, CampaignTime.DaysFromNow(30f))
			{
				this._selectedAnimal = this._possibleAnimals.GetRandomElement<ItemObject>();
				this._isQuestWithMeatOffer = (issueOwner.CurrentSettlement.Village.Hearth <= 300f);
				this._requestedAnimalAmount = MathF.Round((float)((int)(5000f / (float)this._selectedAnimal.Value)) * base.IssueDifficultyMultiplier);
			}

			// Token: 0x06004D2A RID: 19754 RVA: 0x00161D1E File Offset: 0x0015FF1E
			protected override float GetIssueEffectAmountInternal(IssueEffect issueEffect)
			{
				if (issueEffect == DefaultIssueEffects.VillageHearth)
				{
					return -0.2f;
				}
				if (issueEffect == DefaultIssueEffects.IssueOwnerPower)
				{
					return -0.1f;
				}
				return 0f;
			}

			// Token: 0x06004D2B RID: 19755 RVA: 0x00161D41 File Offset: 0x0015FF41
			public override bool DoTroopsSatisfyAlternativeSolution(TroopRoster troopRoster, out TextObject explanation)
			{
				explanation = TextObject.Empty;
				return QuestHelper.CheckRosterForAlternativeSolution(troopRoster, base.GetTotalAlternativeSolutionNeededMenCount(), ref explanation, 2, false);
			}

			// Token: 0x06004D2C RID: 19756 RVA: 0x00161D59 File Offset: 0x0015FF59
			public override bool IsTroopTypeNeededByAlternativeSolution(CharacterObject character)
			{
				return character.Tier >= 2;
			}

			// Token: 0x06004D2D RID: 19757 RVA: 0x00161D67 File Offset: 0x0015FF67
			public override ValueTuple<SkillObject, int> GetAlternativeSolutionSkill(Hero hero)
			{
				return new ValueTuple<SkillObject, int>((hero.GetSkillValue(DefaultSkills.Riding) >= hero.GetSkillValue(DefaultSkills.Trade)) ? DefaultSkills.Riding : DefaultSkills.Trade, 120);
			}

			// Token: 0x06004D2E RID: 19758 RVA: 0x00161D94 File Offset: 0x0015FF94
			public override bool AlternativeSolutionCondition(out TextObject explanation)
			{
				explanation = TextObject.Empty;
				return QuestHelper.CheckRosterForAlternativeSolution(MobileParty.MainParty.MemberRoster, base.GetTotalAlternativeSolutionNeededMenCount(), ref explanation, 2, false) && QuestHelper.CheckGoldForAlternativeSolution(this.GoldRequiredForAlternativeSolution, ref explanation);
			}

			// Token: 0x06004D2F RID: 19759 RVA: 0x00161DC5 File Offset: 0x0015FFC5
			public override IssueBase.IssueFrequency GetFrequency()
			{
				return IssueBase.IssueFrequency.VeryCommon;
			}

			// Token: 0x06004D30 RID: 19760 RVA: 0x00161DC8 File Offset: 0x0015FFC8
			public override bool IssueStayAliveConditions()
			{
				return !base.IssueOwner.CurrentSettlement.IsRaided && !base.IssueOwner.CurrentSettlement.IsUnderRaid;
			}

			// Token: 0x06004D31 RID: 19761 RVA: 0x00161DF1 File Offset: 0x0015FFF1
			public override void AlternativeSolutionStartConsequence()
			{
				GiveGoldAction.ApplyBetweenCharacters(Hero.MainHero, null, this.GoldRequiredForAlternativeSolution, false);
			}

			// Token: 0x06004D32 RID: 19762 RVA: 0x00161E08 File Offset: 0x00160008
			protected override bool CanPlayerTakeQuestConditions(Hero issueGiver, out IssueBase.PreconditionFlags flags, out Hero relationHero, out SkillObject skill)
			{
				flags = IssueBase.PreconditionFlags.None;
				relationHero = null;
				skill = null;
				if (issueGiver.GetRelationWithPlayer() < -10f)
				{
					flags |= IssueBase.PreconditionFlags.Relation;
					relationHero = issueGiver;
				}
				if (FactionManager.IsAtWarAgainstFaction(issueGiver.MapFaction, Hero.MainHero.MapFaction))
				{
					flags |= IssueBase.PreconditionFlags.AtWar;
				}
				return flags == IssueBase.PreconditionFlags.None;
			}

			// Token: 0x06004D33 RID: 19763 RVA: 0x00161E58 File Offset: 0x00160058
			protected override void OnGameLoad()
			{
			}

			// Token: 0x06004D34 RID: 19764 RVA: 0x00161E5A File Offset: 0x0016005A
			protected override void HourlyTick()
			{
			}

			// Token: 0x06004D35 RID: 19765 RVA: 0x00161E5C File Offset: 0x0016005C
			protected override QuestBase GenerateIssueQuest(string questId)
			{
				return new HeadmanVillageNeedsDraughtAnimalsIssueBehavior.HeadmanVillageNeedsDraughtAnimalsIssueQuest(questId, base.IssueOwner, CampaignTime.DaysFromNow(30f), this._selectedAnimal, this._requestedAnimalAmount, this._isQuestWithMeatOffer, this.OfferedMeatAmount, this.RewardGold);
			}

			// Token: 0x06004D36 RID: 19766 RVA: 0x00161E92 File Offset: 0x00160092
			protected override void CompleteIssueWithTimedOutConsequences()
			{
			}

			// Token: 0x17000FCE RID: 4046
			// (get) Token: 0x06004D37 RID: 19767 RVA: 0x00161E94 File Offset: 0x00160094
			protected override int CompanionSkillRewardXP
			{
				get
				{
					return (int)(500f + 700f * base.IssueDifficultyMultiplier);
				}
			}

			// Token: 0x06004D38 RID: 19768 RVA: 0x00161EAC File Offset: 0x001600AC
			protected override void AlternativeSolutionEndWithSuccessConsequence()
			{
				base.IssueOwner.AddPower(10f);
				ChangeRelationAction.ApplyPlayerRelation(base.IssueOwner, 5, true, true);
				base.IssueOwner.CurrentSettlement.Village.Hearth += 30f;
				if (this._isQuestWithMeatOffer)
				{
					ItemObject @object = Game.Current.ObjectManager.GetObject<ItemObject>("meat");
					MobileParty.MainParty.ItemRoster.AddToCounts(@object, this.OfferedMeatAmount);
				}
			}

			// Token: 0x040019ED RID: 6637
			private const int IssueActiveTime = 30;

			// Token: 0x040019EE RID: 6638
			private const int QuestDuration = 30;

			// Token: 0x040019EF RID: 6639
			private const int VillageHearthConstant = 300;

			// Token: 0x040019F0 RID: 6640
			private const int AlternativeSolutionTroopTierRequirement = 2;

			// Token: 0x040019F1 RID: 6641
			private const int CompanionRequiredSkillLevel = 120;

			// Token: 0x040019F2 RID: 6642
			[CachedData]
			private readonly MBList<ItemObject> _possibleAnimals = new MBList<ItemObject>
			{
				Game.Current.ObjectManager.GetObject<ItemObject>("cow"),
				Game.Current.ObjectManager.GetObject<ItemObject>("mule"),
				Game.Current.ObjectManager.GetObject<ItemObject>("sumpter_horse")
			};

			// Token: 0x040019F3 RID: 6643
			[SaveableField(1)]
			private ItemObject _selectedAnimal;

			// Token: 0x040019F4 RID: 6644
			[SaveableField(2)]
			private bool _isQuestWithMeatOffer;

			// Token: 0x040019F5 RID: 6645
			[SaveableField(3)]
			private int _requestedAnimalAmount;
		}

		// Token: 0x02000631 RID: 1585
		public class HeadmanVillageNeedsDraughtAnimalsIssueQuest : QuestBase
		{
			// Token: 0x06004D39 RID: 19769 RVA: 0x00161F2C File Offset: 0x0016012C
			internal static void AutoGeneratedStaticCollectObjectsHeadmanVillageNeedsDraughtAnimalsIssueQuest(object o, List<object> collectedObjects)
			{
				((HeadmanVillageNeedsDraughtAnimalsIssueBehavior.HeadmanVillageNeedsDraughtAnimalsIssueQuest)o).AutoGeneratedInstanceCollectObjects(collectedObjects);
			}

			// Token: 0x06004D3A RID: 19770 RVA: 0x00161F3A File Offset: 0x0016013A
			protected override void AutoGeneratedInstanceCollectObjects(List<object> collectedObjects)
			{
				base.AutoGeneratedInstanceCollectObjects(collectedObjects);
				collectedObjects.Add(this._requestedAnimal);
				collectedObjects.Add(this._questProgressLogTest);
			}

			// Token: 0x06004D3B RID: 19771 RVA: 0x00161F5B File Offset: 0x0016015B
			internal static object AutoGeneratedGetMemberValue_requestedAnimal(object o)
			{
				return ((HeadmanVillageNeedsDraughtAnimalsIssueBehavior.HeadmanVillageNeedsDraughtAnimalsIssueQuest)o)._requestedAnimal;
			}

			// Token: 0x06004D3C RID: 19772 RVA: 0x00161F68 File Offset: 0x00160168
			internal static object AutoGeneratedGetMemberValue_requestedAnimalAmount(object o)
			{
				return ((HeadmanVillageNeedsDraughtAnimalsIssueBehavior.HeadmanVillageNeedsDraughtAnimalsIssueQuest)o)._requestedAnimalAmount;
			}

			// Token: 0x06004D3D RID: 19773 RVA: 0x00161F7A File Offset: 0x0016017A
			internal static object AutoGeneratedGetMemberValue_isQuestWithMeatOffer(object o)
			{
				return ((HeadmanVillageNeedsDraughtAnimalsIssueBehavior.HeadmanVillageNeedsDraughtAnimalsIssueQuest)o)._isQuestWithMeatOffer;
			}

			// Token: 0x06004D3E RID: 19774 RVA: 0x00161F8C File Offset: 0x0016018C
			internal static object AutoGeneratedGetMemberValue_discountValue(object o)
			{
				return ((HeadmanVillageNeedsDraughtAnimalsIssueBehavior.HeadmanVillageNeedsDraughtAnimalsIssueQuest)o)._discountValue;
			}

			// Token: 0x06004D3F RID: 19775 RVA: 0x00161F9E File Offset: 0x0016019E
			internal static object AutoGeneratedGetMemberValue_offeredMeatAmount(object o)
			{
				return ((HeadmanVillageNeedsDraughtAnimalsIssueBehavior.HeadmanVillageNeedsDraughtAnimalsIssueQuest)o)._offeredMeatAmount;
			}

			// Token: 0x06004D40 RID: 19776 RVA: 0x00161FB0 File Offset: 0x001601B0
			internal static object AutoGeneratedGetMemberValue_questProgressLogTest(object o)
			{
				return ((HeadmanVillageNeedsDraughtAnimalsIssueBehavior.HeadmanVillageNeedsDraughtAnimalsIssueQuest)o)._questProgressLogTest;
			}

			// Token: 0x17000FCF RID: 4047
			// (get) Token: 0x06004D41 RID: 19777 RVA: 0x00161FBD File Offset: 0x001601BD
			public override TextObject Title
			{
				get
				{
					return new TextObject("{=MXLcZPaO}Village Needs Draught Animals", null);
				}
			}

			// Token: 0x17000FD0 RID: 4048
			// (get) Token: 0x06004D42 RID: 19778 RVA: 0x00161FCA File Offset: 0x001601CA
			public override bool IsRemainingTimeHidden
			{
				get
				{
					return false;
				}
			}

			// Token: 0x17000FD1 RID: 4049
			// (get) Token: 0x06004D43 RID: 19779 RVA: 0x00161FD0 File Offset: 0x001601D0
			private TextObject QuestStartedLogText
			{
				get
				{
					TextObject textObject = new TextObject("{=V7YG3nKb}{QUEST_GIVER.LINK} told you that {?QUEST_GIVER.GENDER}she{?}he{\\?} needs {.%}{?(REQUESTED_ANIMAL_AMOUNT > 1)}{PLURAL(SELECTED_ANIMAL)}{?}{SELECTED_ANIMAL}{\\?}{.%} for {?QUEST_GIVER.GENDER}her{?}his{\\?} village. {?QUEST_GIVER.GENDER}She{?}He{\\?} asked you to bring {REQUESTED_ANIMAL_AMOUNT} {.%}{?(REQUESTED_ANIMAL_AMOUNT > 1)}{PLURAL(SELECTED_ANIMAL)}{?}{SELECTED_ANIMAL}{\\?}{.%} to {?QUEST_GIVER.GENDER}her{?}him{\\?}.", null);
					textObject.SetTextVariable("REQUESTED_ANIMAL_AMOUNT", this._requestedAnimalAmount);
					textObject.SetTextVariable("SELECTED_ANIMAL", this._requestedAnimal.Name);
					StringHelpers.SetCharacterProperties("QUEST_GIVER", base.QuestGiver.CharacterObject, textObject, false);
					return textObject;
				}
			}

			// Token: 0x17000FD2 RID: 4050
			// (get) Token: 0x06004D44 RID: 19780 RVA: 0x0016202C File Offset: 0x0016022C
			private TextObject QuestStartedLogTextWithMeat
			{
				get
				{
					TextObject textObject = new TextObject("{=7VUNi3zy}{QUEST_GIVER.LINK} will make payment as {MEAT_AMOUNT} meat when the task is done.", null);
					StringHelpers.SetCharacterProperties("QUEST_GIVER", base.QuestGiver.CharacterObject, textObject, false);
					textObject.SetTextVariable("MEAT_AMOUNT", this._offeredMeatAmount);
					return textObject;
				}
			}

			// Token: 0x17000FD3 RID: 4051
			// (get) Token: 0x06004D45 RID: 19781 RVA: 0x00162070 File Offset: 0x00160270
			private TextObject QuestSuccessLogText
			{
				get
				{
					TextObject textObject = new TextObject("{=uubL3Uck}You brought {REQUESTED_ANIMAL_AMOUNT} {.%}{?(REQUESTED_ANIMAL_AMOUNT > 1)}{PLURAL(SELECTED_ANIMAL)}{?}{SELECTED_ANIMAL}{\\?}{.%} to {?QUEST_GIVER.GENDER}her{?}him{\\?} as promised.", null);
					textObject.SetTextVariable("REQUESTED_ANIMAL_AMOUNT", this._requestedAnimalAmount);
					textObject.SetTextVariable("SELECTED_ANIMAL", this._requestedAnimal.Name);
					StringHelpers.SetCharacterProperties("QUEST_GIVER", base.QuestGiver.CharacterObject, textObject, false);
					return textObject;
				}
			}

			// Token: 0x17000FD4 RID: 4052
			// (get) Token: 0x06004D46 RID: 19782 RVA: 0x001620CC File Offset: 0x001602CC
			private TextObject QuestStartedLogTextWithDenars
			{
				get
				{
					TextObject textObject = new TextObject("{=7LjTNs1k}{QUEST_GIVER.LINK} will pay you {REWARD_GOLD}{GOLD_ICON} denars when the task is done.", null);
					StringHelpers.SetCharacterProperties("QUEST_GIVER", base.QuestGiver.CharacterObject, textObject, false);
					textObject.SetTextVariable("REWARD_GOLD", this.RewardGold);
					textObject.SetTextVariable("GOLD_ICON", "{=!}<img src=\"General\\Icons\\Coin@2x\" extend=\"8\">");
					return textObject;
				}
			}

			// Token: 0x17000FD5 RID: 4053
			// (get) Token: 0x06004D47 RID: 19783 RVA: 0x00162124 File Offset: 0x00160324
			private TextObject QuestCanceledWarDeclaredLog
			{
				get
				{
					TextObject textObject = new TextObject("{=vW6kBki9}Your clan is now at war with {QUEST_GIVER.LINK}'s realm. Your agreement with {QUEST_GIVER.LINK} is canceled.", null);
					StringHelpers.SetCharacterProperties("QUEST_GIVER", base.QuestGiver.CharacterObject, textObject, false);
					return textObject;
				}
			}

			// Token: 0x17000FD6 RID: 4054
			// (get) Token: 0x06004D48 RID: 19784 RVA: 0x00162158 File Offset: 0x00160358
			private TextObject PlayerDeclaredWarQuestLogText
			{
				get
				{
					TextObject textObject = new TextObject("{=bqeWVVEE}Your actions have started a war with {QUEST_GIVER.LINK}'s faction. {?QUEST_GIVER.GENDER}She{?}He{\\?} cancels your agreement and the quest is a failure.", null);
					StringHelpers.SetCharacterProperties("QUEST_GIVER", base.QuestGiver.CharacterObject, textObject, false);
					return textObject;
				}
			}

			// Token: 0x17000FD7 RID: 4055
			// (get) Token: 0x06004D49 RID: 19785 RVA: 0x0016218C File Offset: 0x0016038C
			private TextObject QuestGiverVillageRaided
			{
				get
				{
					TextObject textObject = new TextObject("{=gJG0xmAq}{QUEST_GIVER.LINK}'s village {QUEST_SETTLEMENT} was raided. Your agreement with {QUEST_GIVER.LINK} is canceled.", null);
					StringHelpers.SetCharacterProperties("QUEST_GIVER", base.QuestGiver.CharacterObject, textObject, false);
					textObject.SetTextVariable("QUEST_SETTLEMENT", base.QuestGiver.CurrentSettlement.EncyclopediaLinkWithName);
					return textObject;
				}
			}

			// Token: 0x17000FD8 RID: 4056
			// (get) Token: 0x06004D4A RID: 19786 RVA: 0x001621DC File Offset: 0x001603DC
			private TextObject QuestFailedWithTimeOutLogText
			{
				get
				{
					TextObject textObject = new TextObject("{=xvCzjcjU}You failed to deliver {REQUESTED_ANIMAL_AMOUNT} {.%}{?(REQUESTED_ANIMAL_AMOUNT > 1)}{REQUESTED_ANIMAL}{.s}{?}{REQUESTED_ANIMAL}{\\?}{.%} to {QUEST_GIVER.LINK} in time.", null);
					StringHelpers.SetCharacterProperties("QUEST_GIVER", base.QuestGiver.CharacterObject, textObject, false);
					textObject.SetTextVariable("REQUESTED_ANIMAL_AMOUNT", this._requestedAnimalAmount);
					textObject.SetTextVariable("REQUESTED_ANIMAL", this._requestedAnimal.Name);
					return textObject;
				}
			}

			// Token: 0x06004D4B RID: 19787 RVA: 0x00162238 File Offset: 0x00160438
			public HeadmanVillageNeedsDraughtAnimalsIssueQuest(string questId, Hero giverHero, CampaignTime duration, ItemObject requestedAnimal, int requestedAnimalAmount, bool isQuestWithMeatOffer, int offeredMeatAmount, int rewardGold) : base(questId, giverHero, duration, rewardGold)
			{
				this._isQuestWithMeatOffer = isQuestWithMeatOffer;
				this._requestedAnimal = requestedAnimal;
				this._requestedAnimalAmount = requestedAnimalAmount;
				this._offeredMeatAmount = offeredMeatAmount;
				this.CalculateRequestedAnimalCountOnPlayer();
				this.SetDialogs();
				base.InitializeQuestOnCreation();
				if (!isQuestWithMeatOffer && MBRandom.RandomFloat <= 0.7f)
				{
					this._discountValue = (int)((float)this.RewardGold * 0.3f);
				}
			}

			// Token: 0x06004D4C RID: 19788 RVA: 0x001622A8 File Offset: 0x001604A8
			private void QuestAcceptedConsequences()
			{
				base.StartQuest();
				base.AddTrackedObject(base.QuestGiver.CurrentSettlement);
				TextObject textObject = new TextObject("{=yc9rGlzb}Ready to deliver {.%}{?(REQUESTED_ANIMAL_AMOUNT > 1)}{PLURAL(SELECTED_ANIMAL)}{?}{SELECTED_ANIMAL}{\\?}:{.%}", null);
				textObject.SetTextVariable("SELECTED_ANIMAL", this._requestedAnimal.Name);
				textObject.SetTextVariable("REQUESTED_ANIMAL_AMOUNT", this._requestedAnimalAmount);
				this._questProgressLogTest = base.AddDiscreteLog(this.QuestStartedLogText, textObject, this._currentAnimalAmount, this._requestedAnimalAmount, null, false);
				base.AddLog(this._isQuestWithMeatOffer ? this.QuestStartedLogTextWithMeat : this.QuestStartedLogTextWithDenars, false);
			}

			// Token: 0x06004D4D RID: 19789 RVA: 0x00162340 File Offset: 0x00160540
			protected override void SetDialogs()
			{
				this.OfferDialogFlow = DialogFlow.CreateDialogFlow("issue_classic_quest_start", 100).NpcLine(new TextObject("{=msDCQIY7}Thank you, {?PLAYER.GENDER}madam{?}sir{\\?}. [if:convo_grateful][ib:confident]In these hard times, people like you are a gift from Heaven… The village will never forget that you were willing to help. Good luck.", null), null, null).Condition(() => Hero.OneToOneConversationHero == this.QuestGiver).Consequence(new ConversationSentence.OnConsequenceDelegate(this.QuestAcceptedConsequences)).CloseDialog();
				TextObject textObject = new TextObject("{=rRGbn0Sm}Thank you {?PLAYER.GENDER}madam{?}sir{\\?}. [if:convo_focused_happy][ib:normal]You did a great favor to people of {ISSUE_VILLAGE}.", null);
				textObject.SetTextVariable("ISSUE_VILLAGE", base.QuestGiver.CurrentSettlement.EncyclopediaLinkWithName);
				TextObject npcDiscountLine = new TextObject("{=p9rzYV4T}Things have gotten worse for the village, [if:convo_dismayed][ib:nervous2]since we last met {?PLAYER.GENDER}madam{?}sir{\\?}. Is it possible that we could pay you a bit less, what about {DISCOUNTED_REWARD}{GOLD_ICON} denars?", null);
				TextObject npcText = new TextObject("{=4kealpZK}Have you brought the animals {?PLAYER.GENDER}madam{?}sir{\\?}?", null);
				this.DiscussDialogFlow = DialogFlow.CreateDialogFlow("quest_discuss", 100).NpcLine(npcText, null, null).Condition(() => Hero.OneToOneConversationHero == this.QuestGiver).BeginPlayerOptions().PlayerOption(new TextObject("{=CjuVoxaC}Yes, Here are your animals.", null), null).Condition(new ConversationSentence.OnConditionDelegate(this.CheckIfPlayerHasEnoughAnimals)).BeginNpcOptions().NpcOption(npcDiscountLine, delegate()
				{
					if (this._discountValue > 0)
					{
						npcDiscountLine.SetTextVariable("DISCOUNTED_REWARD", this.RewardGold - this._discountValue);
						npcDiscountLine.SetTextVariable("GOLD_ICON", "{=!}<img src=\"General\\Icons\\Coin@2x\" extend=\"8\">");
						return true;
					}
					return false;
				}, null, null).BeginPlayerOptions().PlayerOption(new TextObject("{=KBmAqg54}No problem, you can pay what you can afford.", null), null).NpcLine(textObject, null, null).Consequence(new ConversationSentence.OnConsequenceDelegate(this.QuestSuccessPlayerDeliveredAnimalsWithAcceptingDiscount)).CloseDialog().PlayerOption(new TextObject("{=kYc90hEl}Sorry, but the price is what we agreed on. I can't lower it.", null), null).NpcLine(new TextObject("{=r4pLtP5V}You're right. We agreed on this price. Thank you for your efforts.[if:convo_nervous][ib:normal]", null), null, null).Consequence(new ConversationSentence.OnConsequenceDelegate(this.QuestSuccessPlayerDeliveredAnimalsWithoutAcceptingDiscount)).CloseDialog().EndPlayerOptions().NpcOption(new TextObject("{=l8ezl95j}Thank you {?PLAYER.GENDER}madam{?}sir{\\?}.[if:convo_calm_friendly] Here is what we promised.", null), null, null, null).Consequence(new ConversationSentence.OnConsequenceDelegate(this.QuestSuccessPlayerDeliveredAnimalsNormal)).CloseDialog().EndNpcOptions().PlayerOption(new TextObject("{=PI6ikMsc}I'm working on it.", null), null).NpcLine(new TextObject("{=4MQQf3wp}We are waiting for your arrival. ", null), null, null).CloseDialog().EndPlayerOptions();
			}

			// Token: 0x06004D4E RID: 19790 RVA: 0x00162528 File Offset: 0x00160728
			private void CalculateRequestedAnimalCountOnPlayer()
			{
				int num = 0;
				foreach (ItemRosterElement itemRosterElement in MobileParty.MainParty.ItemRoster)
				{
					if (itemRosterElement.EquipmentElement.Item == this._requestedAnimal)
					{
						num += itemRosterElement.Amount;
					}
				}
				this._currentAnimalAmount = num;
			}

			// Token: 0x06004D4F RID: 19791 RVA: 0x0016259C File Offset: 0x0016079C
			private bool CheckIfPlayerHasEnoughAnimals()
			{
				this.CalculateRequestedAnimalCountOnPlayer();
				return this._currentAnimalAmount >= this._requestedAnimalAmount;
			}

			// Token: 0x06004D50 RID: 19792 RVA: 0x001625B5 File Offset: 0x001607B5
			private void QuestSuccessPlayerDeliveredAnimalsNormal()
			{
				ChangeRelationAction.ApplyPlayerRelation(base.QuestGiver, 5, true, true);
				base.QuestGiver.CurrentSettlement.Village.Hearth += 30f;
				this.ApplyRewards(false);
				base.CompleteQuestWithSuccess();
			}

			// Token: 0x06004D51 RID: 19793 RVA: 0x001625F4 File Offset: 0x001607F4
			private void QuestSuccessPlayerDeliveredAnimalsWithAcceptingDiscount()
			{
				ChangeRelationAction.ApplyPlayerRelation(base.QuestGiver, 8, true, true);
				TraitLevelingHelper.OnIssueSolvedThroughBetrayal(base.QuestGiver, new Tuple<TraitObject, int>[]
				{
					new Tuple<TraitObject, int>(DefaultTraits.Mercy, 30)
				});
				base.QuestGiver.CurrentSettlement.Village.Hearth += 80f;
				this.ApplyRewards(true);
				foreach (Hero hero in base.QuestGiver.CurrentSettlement.Notables)
				{
					if (hero != base.QuestGiver)
					{
						ChangeRelationAction.ApplyPlayerRelation(hero, 3, true, true);
					}
				}
				base.CompleteQuestWithSuccess();
			}

			// Token: 0x06004D52 RID: 19794 RVA: 0x001626B8 File Offset: 0x001608B8
			private void QuestSuccessPlayerDeliveredAnimalsWithoutAcceptingDiscount()
			{
				TraitLevelingHelper.OnIssueSolvedThroughBetrayal(base.QuestGiver, new Tuple<TraitObject, int>[]
				{
					new Tuple<TraitObject, int>(DefaultTraits.Mercy, -20)
				});
				ChangeRelationAction.ApplyPlayerRelation(base.QuestGiver, 5, true, true);
				base.QuestGiver.CurrentSettlement.Village.Hearth += 50f;
				this.ApplyRewards(false);
				base.CompleteQuestWithSuccess();
			}

			// Token: 0x06004D53 RID: 19795 RVA: 0x00162724 File Offset: 0x00160924
			private void ApplyRewards(bool applyDiscount)
			{
				if (this._isQuestWithMeatOffer)
				{
					ItemObject @object = Game.Current.ObjectManager.GetObject<ItemObject>("meat");
					MobileParty.MainParty.ItemRoster.AddToCounts(@object, this._offeredMeatAmount);
					using (List<Hero>.Enumerator enumerator = base.QuestGiver.CurrentSettlement.Notables.GetEnumerator())
					{
						while (enumerator.MoveNext())
						{
							Hero hero = enumerator.Current;
							if (hero != base.QuestGiver)
							{
								ChangeRelationAction.ApplyPlayerRelation(hero, 3, true, true);
							}
						}
						return;
					}
				}
				GiveGoldAction.ApplyBetweenCharacters(null, Hero.MainHero, applyDiscount ? (this.RewardGold - this._discountValue) : this.RewardGold, false);
			}

			// Token: 0x06004D54 RID: 19796 RVA: 0x001627E4 File Offset: 0x001609E4
			protected override void OnCompleteWithSuccess()
			{
				base.AddLog(this.QuestSuccessLogText, false);
				MobileParty.MainParty.ItemRoster.FindIndexOfItem(this._requestedAnimal);
				int num = 0;
				for (int i = MobileParty.MainParty.ItemRoster.Count - 1; i >= 0; i--)
				{
					ItemRosterElement itemRosterElement = MobileParty.MainParty.ItemRoster[i];
					if (itemRosterElement.EquipmentElement.Item == this._requestedAnimal)
					{
						int num2 = (itemRosterElement.Amount >= this._requestedAnimalAmount) ? (this._requestedAnimalAmount - num) : itemRosterElement.Amount;
						EquipmentElement rosterElement = new EquipmentElement(itemRosterElement.EquipmentElement.Item, itemRosterElement.EquipmentElement.ItemModifier, null, false);
						MobileParty.MainParty.ItemRoster.AddToCounts(rosterElement, -num2);
						num += itemRosterElement.Amount;
						if (num >= this._requestedAnimalAmount)
						{
							break;
						}
					}
				}
				TraitLevelingHelper.OnIssueSolvedThroughBetrayal(base.QuestGiver, new Tuple<TraitObject, int>[]
				{
					new Tuple<TraitObject, int>(DefaultTraits.Honor, 30)
				});
				base.QuestGiver.AddPower(10f);
			}

			// Token: 0x06004D55 RID: 19797 RVA: 0x00162904 File Offset: 0x00160B04
			protected override void OnTimedOut()
			{
				base.AddLog(this.QuestFailedWithTimeOutLogText, false);
				base.QuestGiver.AddPower(-10f);
				ChangeRelationAction.ApplyPlayerRelation(base.QuestGiver, -5, true, true);
				base.QuestGiver.CurrentSettlement.Village.Hearth -= 30f;
			}

			// Token: 0x06004D56 RID: 19798 RVA: 0x0016295F File Offset: 0x00160B5F
			protected override void HourlyTick()
			{
			}

			// Token: 0x06004D57 RID: 19799 RVA: 0x00162964 File Offset: 0x00160B64
			protected override void RegisterEvents()
			{
				CampaignEvents.WarDeclared.AddNonSerializedListener(this, new Action<IFaction, IFaction, DeclareWarAction.DeclareWarDetail>(this.OnWarDeclared));
				CampaignEvents.OnClanChangedKingdomEvent.AddNonSerializedListener(this, new Action<Clan, Kingdom, Kingdom, ChangeKingdomAction.ChangeKingdomActionDetail, bool>(this.OnClanChangedKingdom));
				CampaignEvents.VillageBeingRaided.AddNonSerializedListener(this, new Action<Village>(this.OnVillageRaided));
				CampaignEvents.PlayerInventoryExchangeEvent.AddNonSerializedListener(this, new Action<List<ValueTuple<ItemRosterElement, int>>, List<ValueTuple<ItemRosterElement, int>>, bool>(this.OnPlayerInventoryExchange));
				CampaignEvents.MapEventStarted.AddNonSerializedListener(this, new Action<MapEvent, PartyBase, PartyBase>(this.OnMapEventStarted));
			}

			// Token: 0x06004D58 RID: 19800 RVA: 0x001629E4 File Offset: 0x00160BE4
			private void OnMapEventStarted(MapEvent mapEvent, PartyBase attackerParty, PartyBase defenderParty)
			{
				if (QuestHelper.CheckMinorMajorCoercion(this, mapEvent, attackerParty))
				{
					QuestHelper.ApplyGenericMinorMajorCoercionConsequences(this, mapEvent);
				}
			}

			// Token: 0x06004D59 RID: 19801 RVA: 0x001629F8 File Offset: 0x00160BF8
			private void OnPlayerInventoryExchange(List<ValueTuple<ItemRosterElement, int>> purchasedItems, List<ValueTuple<ItemRosterElement, int>> soldItems, bool isTrading)
			{
				int num = 0;
				foreach (ValueTuple<ItemRosterElement, int> valueTuple in purchasedItems)
				{
					ItemRosterElement item = valueTuple.Item1;
					if (item.EquipmentElement.Item == this._requestedAnimal)
					{
						int num2 = num;
						item = valueTuple.Item1;
						num = num2 + item.Amount;
					}
				}
				foreach (ValueTuple<ItemRosterElement, int> valueTuple2 in soldItems)
				{
					ItemRosterElement item = valueTuple2.Item1;
					if (item.EquipmentElement.Item == this._requestedAnimal)
					{
						int num3 = num;
						item = valueTuple2.Item1;
						num = num3 - item.Amount;
					}
				}
				this._currentAnimalAmount += num;
				this._currentAnimalAmount = (int)MathF.Clamp((float)this._currentAnimalAmount, 0f, (float)this._requestedAnimalAmount);
				this._questProgressLogTest.UpdateCurrentProgress(this._currentAnimalAmount);
			}

			// Token: 0x06004D5A RID: 19802 RVA: 0x00162B18 File Offset: 0x00160D18
			private void OnVillageRaided(Village village)
			{
				if (village == base.QuestGiver.CurrentSettlement.Village)
				{
					base.AddLog(this.QuestGiverVillageRaided, false);
					base.CompleteQuestWithCancel(null);
				}
			}

			// Token: 0x06004D5B RID: 19803 RVA: 0x00162B42 File Offset: 0x00160D42
			private void OnClanChangedKingdom(Clan clan, Kingdom oldKingdom, Kingdom newKingdom, ChangeKingdomAction.ChangeKingdomActionDetail detail, bool showNotification = true)
			{
				if (base.QuestGiver.CurrentSettlement.MapFaction.IsAtWarWith(Hero.MainHero.MapFaction))
				{
					base.CompleteQuestWithCancel(this.QuestCanceledWarDeclaredLog);
				}
			}

			// Token: 0x06004D5C RID: 19804 RVA: 0x00162B71 File Offset: 0x00160D71
			private void OnWarDeclared(IFaction faction1, IFaction faction2, DeclareWarAction.DeclareWarDetail detail)
			{
				QuestHelper.CheckWarDeclarationAndFailOrCancelTheQuest(this, faction1, faction2, detail, this.PlayerDeclaredWarQuestLogText, this.QuestCanceledWarDeclaredLog, false);
			}

			// Token: 0x06004D5D RID: 19805 RVA: 0x00162B89 File Offset: 0x00160D89
			protected override void OnFinalize()
			{
			}

			// Token: 0x06004D5E RID: 19806 RVA: 0x00162B8B File Offset: 0x00160D8B
			protected override void InitializeQuestOnGameLoad()
			{
				this.CalculateRequestedAnimalCountOnPlayer();
				this.SetDialogs();
			}

			// Token: 0x040019F6 RID: 6646
			[SaveableField(1)]
			private ItemObject _requestedAnimal;

			// Token: 0x040019F7 RID: 6647
			[SaveableField(2)]
			private int _requestedAnimalAmount;

			// Token: 0x040019F8 RID: 6648
			private int _currentAnimalAmount;

			// Token: 0x040019F9 RID: 6649
			[SaveableField(3)]
			private bool _isQuestWithMeatOffer;

			// Token: 0x040019FA RID: 6650
			[SaveableField(4)]
			private int _discountValue;

			// Token: 0x040019FB RID: 6651
			[SaveableField(5)]
			private int _offeredMeatAmount;

			// Token: 0x040019FC RID: 6652
			[SaveableField(6)]
			private JournalLog _questProgressLogTest;
		}

		// Token: 0x02000632 RID: 1586
		public class HeadmanVillageNeedsDraughtAnimalsIssueBehaviorTypeDefiner : SaveableTypeDefiner
		{
			// Token: 0x06004D5F RID: 19807 RVA: 0x00162B99 File Offset: 0x00160D99
			public HeadmanVillageNeedsDraughtAnimalsIssueBehaviorTypeDefiner() : base(812000)
			{
			}

			// Token: 0x06004D60 RID: 19808 RVA: 0x00162BA6 File Offset: 0x00160DA6
			protected override void DefineClassTypes()
			{
				base.AddClassDefinition(typeof(HeadmanVillageNeedsDraughtAnimalsIssueBehavior.HeadmanVillageNeedsDraughtAnimalsIssue), 1, null);
				base.AddClassDefinition(typeof(HeadmanVillageNeedsDraughtAnimalsIssueBehavior.HeadmanVillageNeedsDraughtAnimalsIssueQuest), 2, null);
			}
		}
	}
}
